﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DockerPlay;
using Xunit;

namespace Tests
{
    public class DockerHelpersTests
    {
        readonly DockerHelper dockerHelper;
        public DockerHelpersTests()
        {
            dockerHelper = new DockerHelper(ConnectionStrings.DockerMachineGA);
        }
        [Fact]
        public async Task GetContainersIdAndStatus_Should_ReturnInstances()
        {
            var containers = await dockerHelper.GetContainersIdAndStatus();
            Assert.NotEmpty(containers);
        }

        [Fact]
        public async Task StartContainer_Should_StartContainer()
        {
            await dockerHelper.StartContainer(ContainerName.ga_mongo_b_27017);
            var status = await dockerHelper.GetContainerStatus(ContainerName.ga_mongo_b_27017);
            Assert.Equal(status, DockerContainerState.running);
        }

        [Fact]
        public async Task StopContainer_Should_StopContainer()
        {
            await dockerHelper.StopContainer(ContainerName.ga_mongo_a_27017);

            var status = await dockerHelper.GetContainerStatus(ContainerName.ga_mongo_a_27017);
            Assert.Equal(status, DockerContainerState.exited);
        }
    }
}
